﻿//Contributor: Nicolas Muniere

using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace Nop.Plugin.Misc.WebServices
{

    [ServiceContract]
    public interface INopService
    {
        /*
        [OperationContract]
        DataSet GetPaymentMethod(string usernameOrEmail, string userPassword);
       
        
        [OperationContract]
        DataSet ExecuteDataSet(string[] sqlStatements, string usernameOrEmail, string userPassword);
        [OperationContract]
        void ExecuteNonQuery(string sqlStatement, string usernameOrEmail, string userPassword);
        [OperationContract]
        object ExecuteScalar(string sqlStatement, string usernameOrEmail, string userPassword);


        [OperationContract]
        List<OrderError> DeleteOrders(int[] ordersId, string usernameOrEmail, string userPassword);
        [OperationContract]
        void AddOrderNote(int orderId, string note, bool displayToCustomer, string usernameOrEmail, string userPassword);
        [OperationContract]
        void UpdateOrderBillingInfo(int orderId, string firstName, string lastName, string phone, string email, string fax, string company, string address1, string address2, string city, string region, string country, string postalCode, string usernameOrEmail, string userPassword);
        [OperationContract]
        void UpdateOrderShippingInfo(int orderId, string firstName, string lastName, string phone, string email, string fax, string company, string address1, string address2, string city, string region, string country, string postalCode, string usernameOrEmail, string userPassword);
        

        [OperationContract]
        void SetOrderPaymentPaidWithMethod(int orderId, string paymentMethodName, string usernameOrEmail, string userPassword);
        [OperationContract]
        void SetOrderPaymentPending(int orderId, string usernameOrEmail, string userPassword);
        [OperationContract]
        void SetOrderPaymentRefund(int orderId, bool offline, string usernameOrEmail, string userPassword);

        [OperationContract]
        List<OrderError> SetOrdersStatusCanceled(int[] ordersId, string usernameOrEmail, string userPassword);*/

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/SetOrderPaymentPaid", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        bool SetOrderPaymentPaid(int orderid, string transactionid, string user, string password);


        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/GetProducts", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        Prodotti GetProducts();

  //      [OperationContract]
  //      [WebInvoke(Method = "POST", UriTemplate = "/ClearCart", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
   //     void ClearCart(string idcustomer, string user, string pwd);


   //     [OperationContract]
   //     [WebInvoke(Method = "POST", UriTemplate = "/AddToCart", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
   //     void AddToCart(string prodid, string quantity, string idcustomer);


  //      [OperationContract]
  //      [WebInvoke(Method = "POST", UriTemplate = "/AddToCart", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
  //      string AddToCart(List<productscart> prodcart);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/ConfirmOrder", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        confirmorderesponse ConfirmOrder(List<productscart> prodcart);

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/GetProductsByCategory/{IDCategory}/{PriceMin}/{PriceMax}/{Brand}/{Search}/{IncludeSubCat}/{Page}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        Prodotti GetProductsByCategory(string IDCategory, string PriceMin, string PriceMax, string Brand, string Search, string IncludeSubCat, string Page);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/PostMessage/{userid}/{touserid}", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
        int PostMessage(string userid, string touserid, string message);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/RegisterUser", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
        EsitoRegistrazione RegisterUser(string nome, string cognome, string indirizzo, string cap, string prov, string citta, string country, string user, string password);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/ValidateUser", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
        int ValidateUser(string user, string password);

        [OperationContract]
        [WebInvoke(Method = "POST",
                        UriTemplate = "/PostData",
                        BodyStyle = WebMessageBodyStyle.WrappedRequest,
            ResponseFormat = WebMessageFormat.Json,
            RequestFormat = WebMessageFormat.Json)]
        string PostData(string data);
    }

    public class EsitoRegistrazione
    {
        [DataMember]
        public int esito { get; set; }

        [DataMember]
        public int iduser { get; set; }

        [DataMember]
        public string message { get; set; }
    }

    public class Prodotti
    {
        [DataMember]
        public List<products> products { get; set; }
    }


    [DataContract(Name = "productscart")]
    public class productscart
    {
        [DataMember]
        public int prodid { get; set; }
        [DataMember]
        public int qty { get; set; }
        [DataMember]
        public int idcustomer { get; set; }
        [DataMember]
        public string tel { get; set; }
        [DataMember]
        public string pag { get; set; }
        [DataMember]
        public string user { get; set; }
        [DataMember]
        public string pwd { get; set; }
    }

    [DataContract(Name = "confirmorderesponse")]
    public class confirmorderesponse
    {
        [DataMember]
        public int esito { get; set; }
        [DataMember]
        public int idordine { get; set; }
        [DataMember]
        public string message { get; set; }

        public confirmorderesponse()
        {
            message = "";
        }
    }

    [DataContract(Name="products")]
    public class products
    {
        [DataMember]
        public string name { get; set; }
        [DataMember]
        public string id { get; set; }
        [DataMember]
        public double origprice { get; set; }
        [DataMember]
        public double price { get; set; }
        [DataMember]
        public Groups groups { get; set; }
        [DataMember]
        public Desc desc { get; set; }
        [DataMember]
        public Imgs imgs { get; set; }
        [DataMember]
        public int ship { get; set; }
    }

    [DataContract]
    public class Groups
    {
        [DataMember]
        public bool spotlight { get; set; }
        [DataMember]
        public bool featured { get; set; }
        [DataMember]
        public string category { get; set; }
    }

    [DataContract]
    public class Desc
    {
        [DataMember]
        public string breve { get; set; }
        [DataMember]
        public string lunga { get; set; }
    }
    

    [DataContract]
    public class Imgs
    {
        [DataMember]
        public string main { get; set; }
        [DataMember]
        public string thumb { get; set; }
        [DataMember]
        public string spotlight { get; set; }
    }
}
